package com.neu.controller;

import com.neu.bean.User;
import com.neu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
public class UserController {

    @Autowired
    private UserService userService;

   @PostMapping(value="/user/regist",produces ="application/json; charset=utf-8")
    public Map<String,String> addUser(@RequestBody User user){
        Map<String,String > retMap=new HashMap<>();

       int count=userService.addUser(user);
        //添加成功
        if(count>0){
            retMap.put("result","true");
            retMap.put("msg","成功");
        }else{
            retMap.put("result","false");
            retMap.put("msg","失败");
        }

        return retMap;
    }
}
